import { IPSAppCounterRef } from '../control/ipsapp-counter-ref';
import { IPSAppIndexView } from './ipsapp-index-view';
import { IPSAppView } from './ipsapp-view';
import { PSAppViewImpl } from './psapp-view-impl';
import { IPSSysImage } from '../../res/ipssys-image';

export class PSAppIndexViewImpl extends PSAppViewImpl implements IPSAppIndexView {
  get appIconPath(): string {
    return this.M.appIconPath;
  }

  get appIconPath2(): string {
    return this.M.appIconPath2;
  }

  get appSwitchMode(): 0 | 1 {
    return this.M.appSwitchMode;
  }

  get bottomInfo(): string {
    return this.M.bottomInfo;
  }

  get caption(): string {
    return this.M.caption;
  }

  protected defpsappview: IPSAppView | null = null;

  getDefPSAppView(): IPSAppView | null {
    if (this.defpsappview != null) return this.defpsappview;
    const value = this.M.getDefPSAppView;
    if (value == null) {
      return null;
    }
    this.defpsappview = this.getPSModel4('app.view.IPSAppView', value, 'getDefPSAppView') as IPSAppView;
    return this.defpsappview;
  }

  get defPSAppView(): IPSAppView | null {
    return this.getDefPSAppView();
  }

  getDefPSAppViewMust(): IPSAppView {
    const value = this.getDefPSAppView();
    if (value == null) {
      throw new Error('未指定默认内容视图');
    }
    return value;
  }

  get headerInfo(): string {
    return this.M.headerInfo;
  }

  get mainMenuAlign(): 'LEFT' | 'TOP' | 'CENTER' | 'TREEEXP' | 'TABEXP_TOP' | 'TABEXP_LEFT' | 'TABEXP_BOTTOM' | 'TABEXP_RIGHT' | 'NONE' {
    return this.M.mainMenuAlign;
  }

  protected pssysimage: IPSSysImage | null = null;

  getPSSysImage(): IPSSysImage | null {
    if (this.pssysimage != null) return this.pssysimage;
    const value = this.M.getPSSysImage;
    if (value == null) {
      return null;
    }
    this.pssysimage = this.getPSModel4('res.IPSSysImage', value, 'getPSSysImage') as IPSSysImage;
    return this.pssysimage;
  }

  get psSysImage(): IPSSysImage | null {
    return this.getPSSysImage();
  }

  getPSSysImageMust(): IPSSysImage {
    const value = this.getPSSysImage();
    if (value == null) {
      throw new Error('未指定图标对象');
    }
    return value;
  }

  protected portalpsappcounterref: IPSAppCounterRef | null = null;

  getPortalPSAppCounterRef(): IPSAppCounterRef | null {
    if (this.portalpsappcounterref != null) return this.portalpsappcounterref;
    const value = this.M.getPortalPSAppCounterRef;
    if (value == null) {
      return null;
    }
    this.portalpsappcounterref = this.getPSModel4('app.control.IPSAppCounterRef', value, 'getPortalPSAppCounterRef') as IPSAppCounterRef;
    return this.portalpsappcounterref;
  }

  get portalPSAppCounterRef(): IPSAppCounterRef | null {
    return this.getPortalPSAppCounterRef();
  }

  getPortalPSAppCounterRefMust(): IPSAppCounterRef {
    const value = this.getPortalPSAppCounterRef();
    if (value == null) {
      throw new Error('未指定门户应用计数器引用');
    }
    return value;
  }

  get subCaption(): string {
    return this.M.subCaption;
  }

  get title(): string {
    return this.M.title;
  }

  get blankMode(): boolean {
    return this.M.blankMode;
  }

  get defaultPage(): boolean {
    return this.M.defaultPage != null ? this.M.defaultPage : false;
  }

  get enableAppSwitch(): boolean {
    return this.M.enableAppSwitch;
  }

  get enableDP(): boolean {
    return this.M.enableDP;
  }

  get enableWF(): boolean {
    return this.M.enableWF != null ? this.M.enableWF : false;
  }

  get cls(): string {
    return 'PSAppIndexViewImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.view.IPSAppIndexView') return true;
    return super.instanceof(cls);
  }
}
